import { http } from '@/utils/http/axios';

export interface BasicResponseModel<T = any> {
  code: number;
  message: string;
  data: T;
}

export interface BasicPageParams {
  pageNumber: number;
  pageSize: number;
  total: number;
}

/**
 * @description: 获取用户信息
 */
export function getUserInfo(params) {
  return http.request({
    url: '/user/info',
    method: 'GET',
    params,
  });
}

/**
 * @description: 添加/编辑用户
 */
export function addUsur(params) {
  return http.request({
    url: '/user/add',
    method: 'POST',
    params,
  });
}

/**
 * @description: 编辑用户
 */
export function editUsur(params) {
  return http.request({
    url: '/user/edit',
    method: 'POST',
    params,
  });
}

/**
 * @description: 用户信息
 */
export function userInfo(params) {
  return http.request({
    url: '/user/info',
    method: 'GET',
    params,
  });
}

/**
 * @description: 删除用户
 */
export function delUser(params) {
  return http.request({
    url: '/user/delete',
    method: 'POST',
    params,
  });
}

/**
 * @description: 用户登录
 */
export function login(params) {
  return http.request<BasicResponseModel>(
    {
      url: '/auth/login',
      method: 'POST',
      params,
    },
    {
      isTransformResponse: false,
    },
  );
}

/**
 * @description: 用户修改密码
 */
export function changePassword(params) {
  return http.request({
    url: '/user/editPwd',
    method: 'POST',
    params,
  });
}

/**
 * @description: 修改用户信息
 */
export function editUserInfo(params) {
  return http.request({
    url: '/user/edit',
    method: 'POST',
    params,
  });
}

/**
 * @description: 用户登出
 */
export function logout(params) {
  return http.request({
    url: '/user/doLogout',
    method: 'POST',
    params,
  });
}

/**
 * @description: 获取用户列表
 */
export function getUserList(params) {
  return http.request({
    url: '/user/list',
    method: 'GET',
    params,
  });
}
